import {
  getCSBList
} from '../../../api/check'
Component({

  /**
   * 组件的属性列表
   */
  properties: {
    value: {
      type: Number,
      value: 0,
      optionalTypes: [String, Object],
      observer: function (newVal, oldVal) {
        // 属性值变化时执行-回显数据
        this.setData({
          selected: newVal
        })
      }
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    selected: '', //当前选中的值
    options: []
  },
  created() {
    this.getDatas()
  },
  /**
   * 组件的方法列表
   */
  methods: {
    // 获取所属行业的枚举值
    getDatas() {
      const options = wx.getStorageSync('zwbj')
      if (options && options.length > 0) {
        this.setData({
          options: options
        })
      } else {
        getCSBList({
          type: 'zwbj'
        }).then(res => {
          wx.setStorageSync('zwbj', res)
          this.setData({
            options: res
          })
        })
      }
    },
    onChange(event) {
      this.setData({
        selected: event.detail,
      });
      this.triggerEvent('change', event.detail)
    }
  }
})